#ifndef TEXT_FACTORY_CPP
#define TEXT_FACTORY_CPP
#include <gtkmm-2.4/gtkmm.h>
#include <glibmm-2.4/glibmm.h>
#include <gdkmm-2.4/gdkmm.h>
#include <gdkmm-2.4/gdkmm/pixbuf.h>
#include <libgnomevfs/gnome-vfs.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <Magick++.h>
#include <boost/tokenizer.hpp>
#include <ctime>
#include <cstdlib>
using namespace boost;
using namespace std;
using namespace Magick;

typedef unsigned short qc;

class textFactory
{
	protected:
		Color *clear;
		double R,G,B;
		Geometry *size;
		int width, height;
		Image *image;
		string fname;
		static string* rfname(int length)
		{
			string* fn;
			fn = new string("");
			register int index;
			char* t;
			t = (char*)malloc((52)*sizeof(char));
			char* t1;
			t1 = t;
			for(int a = 'A'; a<='Z'; a++)
			{
				*(t++)=(char)a;
			}
			for(int a = 'a'; a<='z'; a++)
			{
				*(t++)=(char)a;
			}
			for(int x=0;x<length;x++)
			{
				index = rand()%(52);
				fn->append((t1+index),1);
			}
			return fn;
		}

		public:
		textFactory(unsigned int w, unsigned int h, qc red=0, qc green=0, qc blue=0, qc alpha=0) : 
			width(w),height(h)
		{
			image = new Image(Geometry(w,h), Color(
						(qc)0xff,(qc)0xff,(qc)0xff,
						(qc)0xff));
			srand(time(NULL));
			string *s = rfname(12);
			fname = *s;
			fname = fname + ".png";

			Color fontC(red,green,blue,alpha);

			image->strokeColor(fontC);
			image->font("helvetica");
			image->fontPointsize(72);
		}

		void makeWatermarkImage(string text,double rotation=0)
		{
			image->draw(DrawableText(0,height/2,text));
			image->rotate(rotation);
			image->trim();
			//image->write(fname);
		}

		//string getWatermarkPath(){return fname;}
		Image* getWatermark(){return image;}
};

#endif
